package com.mt.components.itemRenderer{
	
	import com.mt.components.general.Node;
	import com.mt.components.log.LogFactory;
	import com.mt.components.log.Logger;
	
	import flash.events.Event;
	
	import mx.controls.Alert;
	import mx.controls.CheckBox;
	import mx.controls.listClasses.IListItemRenderer;
	import mx.controls.listClasses.ListBase;
	
	/**      
	 * 类名称：EListCheckBoxItemRenderer  <br>
	 * 类描述：<br>
	 * 创建人：MaTeng<br>
	 * 创建时间：Jul 23, 2012 4:10:53 PM<br>
	 * 修改人：MaTeng<br>
	 * 修改时间：Jul 23, 2012 4:10:53 PM <br>  
	 */
	public class ListCheckBoxItemRenderer extends CheckBox implements IListItemRenderer {
		
		private static var logger:Logger = LogFactory.getLogger(ListCheckBoxItemRenderer);
		
		public function ListCheckBoxItemRenderer(){
			super();
		}
		
		override public function set data(value:Object):void {
			if(value && value is Node){
				this.selected = value.isSelected;
			}
			super.data = value;
		}
		
		private function click(e:Event):void {
			if(this.data is Node){
				this.data.isSelected = !this.data.isSelected;
			}else{
				throw new Error("EMultipleSelector's model is not ENode");
			}
		}
		
		override protected function commitProperties():void {
			super.commitProperties();
			this.addEventListener(Event.CHANGE , click);
		}
	}
}